package com.example.blogsystem.mapper;

import com.example.blogsystem.model.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.jws.soap.SOAPBinding;

@Mapper
public interface UserMapper {
    @Select("select * from user where user_name = #{userName}")
    public User queryUserByName(String userName);

    @Select("select * from user where id = #{id}")
    public User queryUserById(Integer id);
    @Insert("insert into user (user_name, password, email) values(#{userName}, #{password}, #{email})")
    public void insertUser(User user);

    @Update("update user set user_name = #{userName}," +
            "github_url = #{githubUrl}," +
            "avatar_path = #{avatarPath} " +
            "where id = #{id}")
    public void updateUser(User user);

    @Select("select * from user where email = #{email}")
    public User queryUserEmail(String email);

    @Update("update user set password = #{password} where email = #{email}")
    void updatePassword(User user);
}
